<admintpl file="header" />
</head>

<body>
<div class="wrap js-check-wrap">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:U('Message/Index')}">留言墙</a></li>
            <li><a href="{:U('Message/addwall')}">创建留言墙</a></li>
            <li><a href="{:U('Message/manage?wall_id='.$wall_id)}">留言管理</a></li>
            <li class="active"><a href="{:U('Message/addmessage?wall_id='.$wall_id)}">创建留言</a></li>
        </ul>

        <form method="post" class="form-horizontal js-ajax-form" action="{:U('Admin/Message/addmessage')}">
            <div class="control-group">
                <td>
                    <table class="table table-hover table-bordered table-list">
                        <tr id="set_colname" >
                            <td style="width: 200px;">*用户名</td>
                            <td>
                                <input type="text" name="message_name" value="" style="width: 500px;">
                            </td>
                        </tr>

                        <tr>
                            <td class="span1 control-label" style="width: 90px;">封面图片：</td>
                            <td>
                                <div class="span4 wrapper">
                                    <div id="uploader-image">
                                        <div id="fileList" class="uploader-list">
                                            <div id="imageDiv" class="file-item thumbnail" style="width:150px;height: 150px;">
                                                <?php
										if(!empty($news_info['cover_image'])){
									?>
                                                <img id="imagePreview" src="{$news_info.cover_image}" style="width:150px;height: 140px;">
                                                <?php
										}else{
										?>
                                                <img id="imagePreview" src="__PUBLIC__/images/furley_bg.png" style="width:150px;height: 140px;">
                                                <?php
										}
										?>
                                                <div id="picker" class="info">选择图片&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                                <input style="display:none;" type="file" id="imageFile" name="imageFile" >
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>

                        </tr>
                        <tr id="set_source_tr">
                            <td style="width: 200px;">留言来源</td>
                            <td>
                                <select class="select_2" name="source" id="set_source" style="width: 105px;">
                                    <option value="">--请选择--</option>
                                    <option value="0" >微信用户</option>
                                    <option value="1"  >APP用户</option>
                                    <option value="2"  >竞猜用户</option>
                                </select>
                            </td>
                        </tr>
                        <tr id="set_type_tr">
                            <td style="width: 200px;">类型</td>
                            <td>
                                <select class="select_2" name="type" id="set_type" style="width: 105px;">
                                    <option value="">--请选择--</option>
                                    <option value="0" >测试用户</option>
                                    <option value="1"  >现场观众</option>
                                    <option value="2"  >线上用户</option>
                                    <option value="3"  >奖池用户</option>
                                    <option value="4"  >其它</option>
                                </select>
                            </td>
                        </tr>
                        <tr id="set_radio" >
                            <td style="width: 200px;">留言内容</td>
                            <td>
                                <textarea rows="3" cols="20" name="content"></textarea>
                            </td>
                        </tr>
                    </table>
                <input type="hidden" name="wall_id" id="hidden_id" value="{$wall_id}">
            </div>
            <div class="form-actions" style="padding-left:260px;">
                <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
                &nbsp;&nbsp;<a class="btn" href="{:U('Admin/Message/Index')}">{:L('BACK')}</a>
            </div>
        </form>
    </div>

</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script>
    function html5Reader(file, previewId){
        var file = file.files[0];
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('#'+previewId).attr('src', this.result);
        }
    }
    function image_change(fileId, previewId) {
        var pic = document.getElementById(previewId),
                file = document.getElementById(fileId);

        var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

        // gif在IE浏览器暂时无法显示
        if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
            alert("图片的格式必须为png或者jpg或者jpeg格式！");
            return;
        }
        var isIE = navigator.userAgent.match(/MSIE/)!= null,
                isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

        if(isIE) {
            file.select();
            var realLocalPath = document.selection.createRange().text;

            // IE6浏览器设置img的src为本地路径可以直接显示图片
            if (isIE6) {
                pic.src = realLocalPath;
            }else {
                // 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
                pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
                // 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
                pic.src = '';
            }
        }else {
            html5Reader(file, previewId);
        }
    }

    $("#picker").click(function(){
        $("#imageFile").click();
    });

    $("#imageFile").change(function(){
        image_change('imageFile', 'imagePreview');
    });

</script>

</body>
</html>